package com.atguigu.day20.exer;

import java.util.TreeSet;

public class Test2 {
    public static void main(String[] args) {
        TreeSet<Circle> tree  = new TreeSet<>();
        tree.add(new Circle(1.5));
        tree.add(new Circle(2.5));
        tree.add(new Circle(1.5));
        tree.add(new Circle(2.5));

        for (Circle circle : tree) {
            System.out.println(circle);
        }
    }
}
class Circle implements Comparable<Circle>{
    private double radius;

    public Circle(double radius) {
        this.radius = radius;
    }

    public double getRadius() {
        return radius;
    }

    public void setRadius(double radius) {
        this.radius = radius;
    }

    @Override
    public String toString() {
        return "Circle{" +
                "radius=" + radius +
                '}';
    }

    @Override
    public int compareTo(Circle o) {
        return Double.compare(this.radius, o.radius);
    }
}
